const http = require('http')
// 导入数据库
const {executeSql} = require("./shopping");

// 端口号
const port = 8888;
// 主机地址
const host = "127.0.0.1";

const app = http.createServer((req, res) => {
    if (req.method === "GET" && req.url === "/api/demo") {
        // 定义sql语句，查询map表中的所有数据
        let sql = `select * from map`;

        // executeSql返回的是promise
        executeSql(sql).then((result) => {
            // result就是map表中的所有数据
            res.end(JSON.stringify(result));
        });
    }
});

app.listen(80,()=>{
    console.log('http://127.0.0.1')
})
